import Vue from "vue";
import VueRouter from "vue-router";
import Main from "@/views/Main.vue";

Vue.use(VueRouter);
//全局路由配置， 重复路由不报错
const VueRouterPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(to) {
  return VueRouterPush.call(this, to).catch((err) => err);
};
const VueRouterReplace = VueRouter.prototype.replace;
VueRouter.prototype.replace = function replace(to) {
  return VueRouterReplace.call(this, to).catch((err) => err);
};
const routes = [
  {
    //引导页面
    path: "/",
    name: "Main",
    component: Main,
  },
  {
    path: "/Main",
    name: "Main",
    component: () => import("@/views/Main.vue"),
    redirect: "/Main/websiteManage",
    children: [
      {
        path: "/Main/websiteManage",
        name: "网站管理",
        component: () => import("@/views/websiteManage/index.vue"),
      },
      {
        path: "/Main/spaceManage",
        name: "空间管理",
        component: () => import("@/views/spaceManage/index.vue"),
      },
      {
        path: "/Main/accountManage",
        name: "账号管理",
        component: () => import("@/views/accountManage/index.vue"),
      },
      {
        path: "/Main/domainManage",
        name: "域名管理",
        component: () => import("@/views/domainManage/index.vue"),
      },
      {
        path: "/Main/helpCenter",
        name: "帮助中心",
        component: () => import("@/views/helpCenter/index.vue"),
      },
      {
        path: "/Main/SEOOptimization",
        name: "SEO优化",
        component: () => import("@/views/SEOOptimization/index.vue"),
      },
      {
        path: "/Main/recycleBin",
        name: "回收站",
        component: () => import("@/views/recycleBin/index.vue"),
      },
      {
        path: "/Main/systemManage",
        name: "系统管理",
        component: () => import("@/views/systemManage/index.vue"),
      },
      {
        path: "/Main/recycleBin",
        name: "回收站",
        component: () => import("@/views/recycleBin/index.vue"),
      },
      {
        path: "/Main/articleManage",
        name: "文章管理",
        component: () => import("@/views/articleManage/index.vue"),
        meta: {
          keepAlive: true // 需要缓存
        }
      },
      {
        path: "/Main/productManage",
        name: "产品管理",
        component: () => import("@/views/productManage/index.vue"),
      },
      {
        path: "/Main/videoManage",
        name: "视频管理",
        component: () => import("@/views/videoManage/index.vue"),
      },
    ],
  },
  {
    path: "/Main/websiteManage/createNewWebsite",
    name: "创建新网站",
    component: ()=> import("@/views/websiteManage/createNewWebsite/index.vue")
  },
  {
    path: "/Main/websiteManage/websiteList",
    name: "网站子页面列表",
    component: ()=> import("@/views/websiteManage/websiteList/index.vue")
  },
  {
    path: "/Main/websiteManage/date",
    name: "数据页面",
    component: ()=> import("@/views/websiteManage/date.vue")
  },
  {
    path: "/Main/websiteManage/massageBoard",
    name: "留言",
    component: () => import("@/views/websiteManage/massageBoard/index.vue")
  },
  {
    path: "/Main/websiteManage/websiteSetting",
    name: "网站设置",
    component: ()=> import("@/views/websiteManage/websiteSetting/index.vue")
  },
  {
    path: "/Main/articleManage/createModel",
    name: "文章模板",
    component: ()=> import("@/views/articleManage/components/showModel.vue")
  },
  {
    path: "/Main/editor",
    name: "编辑器",
    component: ()=> import("@/views/editor/index.vue")
  },
  {
    path: "/Main/articleManage/editor",
    name: "文章编辑",
    component: ()=> import("@/views/articleManage/createNewArticle/index.vue"),
    // meta: {
    //   keepAlive: true // 需要缓存
    // }
  },
];

const router = new VueRouter({
  routes,
});

export default router;
